﻿CREATE VIEW dbo.vsec_ListWhere
AS
SELECT     Loan.ID AS LoanID, LU.[Customer #] AS UsixID, LU.CompanyID AS U, BCB.Name, BCB.SSN, CarInfo.VIN, COALESCE (D.Name, D.Name) AS Dealer, 
                      S.Name AS Status, CH.Nick AS ContractHolder
FROM         dbo.t_State AS S INNER JOIN
                      dbo.t_Dealer_SalesPersons AS D_SP INNER JOIN
                      dbo.t_Loan AS Loan ON D_SP.ID = Loan.DealerSalesPersonID INNER JOIN
                      dbo.t_Dealer AS D ON D_SP.DealerID = D.ID INNER JOIN
                      dbo.t_CarInfo AS CarInfo ON Loan.ID = CarInfo.LoanID INNER JOIN
                      dbo.fs_Loans_Read(DEFAULT, DEFAULT) AS fs_Loans ON Loan.ID = fs_Loans.LoanID ON S.ID = Loan.StatusID INNER JOIN
                      dbo.v_ContractHolder AS CH ON Loan.ContractHolderID = CH.ID INNER JOIN
                      dbo.v_BorrowerCoBorrower AS BCB ON Loan.ID = BCB.LoanID LEFT OUTER JOIN
                      usix.t_CustomerFile_Export AS LU ON Loan.ID = LU.LoanID

GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[58] 4[15] 2[17] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1[38] 4) )"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "fs_Loans"
            Begin Extent = 
               Top = 231
               Left = 688
               Bottom = 295
               Right = 839
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "CarInfo"
            Begin Extent = 
               Top = 751
               Left = 92
               Bottom = 890
               Right = 244
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "LU"
            Begin Extent = 
               Top = 594
               Left = 38
               Bottom = 702
               Right = 237
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "D"
            Begin Extent = 
               Top = 485
               Left = 132
               Bottom = 594
               Right = 283
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "CH"
            Begin Extent = 
               Top = 318
               Left = 38
               Bottom = 426
               Right = 194
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "D_SP"
            Begin Extent = 
               Top = 208
               Left = 103
               Bottom = 317
               Right = 254
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "S"
            Begin Extent = 
               Top = 6
               Left = 38
               Bottom = 114
               Right = 189
            End
            DisplayFlags = 280
            TopColumn =', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'vsec_ListWhere';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'0
         End
         Begin Table = "Loan"
            Begin Extent = 
               Top = 73
               Left = 315
               Bottom = 383
               Right = 495
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "BCB"
            Begin Extent = 
               Top = 530
               Left = 618
               Bottom = 623
               Right = 769
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 11
         Width = 284
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1845
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 9330
         Alias = 1815
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'vsec_ListWhere';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'vsec_ListWhere';

